home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Offline Browsing / HTTrack.exe / data1.cab / Sources / src / configure next >
Encoding:
Text File  |  2001-04-28  |  8.4 KB  |  338 lines

  1. #!/bin/sh
  2. # No, this isn't generated by autoconf
  3. # Some parts are inspired by autoconf (Free Software Foundation), however
  4. # And the idea is slightly the same
  5.  
  6. # Usage:
  7. # './configure' and then 'make' and 'make install', or
  8. # './configure --make --install'
  9.  
  10. SHELL=/bin/sh
  11.  
  12. ac_prev=
  13. for ac_option
  14. do
  15.   # If the previous option needs an argument, assign it.
  16.   if test -n "$ac_prev"; then
  17.     eval "$ac_prev=\$ac_option"
  18.     ac_prev=
  19.     continue
  20.   fi
  21.  
  22.   case "$ac_option" in
  23.     -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  24.     *) ac_optarg= ;;
  25.   esac
  26.  
  27.   case "$ac_option" in
  28.  
  29.   --pthread | --thread)     THREADS=1   ;;
  30.   --nopthread | --nothread) THREADS=0   ;;
  31.  
  32.   --longlong)               LONGLONG=1  ;;
  33.   --nolonglong)             LONGLONG=0  ;;
  34.  
  35.   --inaddrt)                NODECLINADDRT=0 ;;
  36.   --noinaddrt)              NODECLINADDRT=1 ;;
  37.  
  38.   --useuid)                 NOUID=0     ;;
  39.   --nouseuid)               NOUID=1     ;;
  40.  
  41.   --useftime)               NOFTIME=0   ;;
  42.   --nouseftime)             NOFTIME=1   ;;
  43.  
  44.   --system=*)               SYSTEMTYPE="$ac_optarg" ;;
  45.   --system)                 ac_prev=SYSTEMTYPE ;;
  46.  
  47.   --debug)                  OTYPE="-O0 -g3" ;;
  48.  
  49.   --make)                   DOMAKE=1    ;;
  50.   --install)                DOINSTALL=1 ;;
  51.   --cls)
  52.     strip_cr *.c *.h
  53.     rm -f httrack 2>/dev/null
  54.     chmod 644 *.h *.c
  55.     chmod u+w *
  56.     exit    
  57.     ;;
  58.   -bindir | --bindir | --bindi | --bind | --bin | --bi)
  59.     ac_prev=bindir ;;
  60.   -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
  61.     bindir="$ac_optarg" ;;
  62.  
  63.   --help)
  64.     cat <<EOF
  65. --nopthread  : do not use threads (pthread.h)
  66. --pthread    : do     use threads (pthread.h)
  67. --nolonglong : do not use 64-bit int
  68. --longlong   : do     use 64-bit int
  69. --noinaddrt  : do not redeclare in_addr_t
  70. --inaddrt    : do     redeclare in_addr_t
  71. --nouseuid   : do not use setuid()/setgid()
  72. --useuid     : do     use setuid()/setgid()
  73. --nouseftime : do not use ftime()
  74. --useftime   : do     use ftime()
  75. --system=<type> : override system type (uname) (types: 'Default','Linux','SunOS','AIX')
  76. --make       : 'make' after configure
  77. --install    : 'make install' after configure
  78. --debug      : add debug information (for gdb)
  79. EOF
  80.   exit
  81.   ;;
  82.  
  83.   *) echo "Unrecognized option: $ac_option" 
  84.      exit 
  85.      ;;
  86.  
  87.   esac
  88.  
  89. done
  90.  
  91. echo "Welcome to HTTrack Website Copier!"
  92. echo "Type in ./configure --help for more details"
  93. echo "If this script fails, you can enter supplemental options through '--option=value'"
  94. echo "or enter in manual make, through 'make help'"
  95. echo ""
  96.  
  97. if cp -f Makefile.in Makefile; then
  98.  
  99. SEDEXEC=
  100.  
  101. # System (OS) type?
  102. printf "Checking for OS type.. "
  103. if test -z "$SYSTEMTYPE"; then
  104.     SYSTEMTYPE="`uname`"
  105. fi
  106. case "$SYSTEMTYPE" in 
  107.     SunOS) printf "SunOS/Solaris\n"; 
  108.                PLATFORM=0
  109.                SOLSOCK=1
  110.                ;;
  111.     AIX)   printf "AIX\n";           PLATFORM=2 ;;
  112.     *)     printf "Linux type\n";    PLATFORM=3 ;;
  113. esac
  114.  
  115. WTYPE="-Wall -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wnested-externs"
  116.  
  117. if test -z "$OTYPE"; then
  118.     OTYPE="-O3"
  119. fi
  120.  
  121. # Binaries location
  122. if test -z "$BINPATH"; then
  123. printf "Checking for bin directory.. "
  124. if test -d "/usr/bin"; then
  125.     BINPATH="/usr/bin"
  126. else
  127.     BINPATH="/bin"
  128. fi
  129. printf "$BINPATH\n"
  130. else
  131.     echo "Overriding BINPATH=$BINPATH"
  132. fi
  133.  
  134. # Prefix location
  135. if test -z "$PREFIX"; then
  136.     printf "Checking for usr directory.. "
  137.     PREFIX="/usr"
  138.     printf "$PREFIX\n"
  139. else
  140.     echo "Overriding PREFIX=$PREFIX"
  141. fi
  142.  
  143. # 64-bit (long long) cause some troubles to some processors
  144. # because some alignements aren't properly defined
  145. # we only accept 64-bit on tested processors here
  146. if test -z "$LONGLONG"; then
  147. printf "Checking for long long.. "
  148. LONGLONG=
  149. if grep "long long" /usr/include/sys/types.h >/dev/null; then
  150. if uname -a|grep -E ' i[3-9]86 ' >/dev/null; then
  151.     LONGLONG=1
  152. fi
  153. fi
  154. if test -n "$LONGLONG"; then
  155.     printf "supported\n"
  156. else
  157.     printf "not tested/supported. Use --LONGLONG=1 to override\n"
  158. fi
  159. else
  160.     echo "Overriding LONGLONG=$LONGLONG"
  161. fi
  162.  
  163. # Do we not have to redeclare in_addr_t ?
  164. # Sometimes this type is defined, or not..
  165. if test -z "$NODECLINADDRT"; then
  166. printf "Checking for in_addr_t declaration in /usr/include/arpa/inet.h.. "
  167. if grep "in_addr_t" /usr/include/arpa/inet.h >/dev/null; then
  168.     printf "found, do not redeclare\n"
  169.     NODECLINADDRT=1
  170. else
  171.     printf "not found, declaring\n"
  172.     NODECLINADDRT=
  173. fi
  174. else
  175.     echo "Overriding NODECLINADDRT=$NODECLINADDRT"
  176. fi
  177.  
  178. # Sometimes, pthread.h doesn't exists on some systems
  179. # This is sad, because it speeds up some useful things, like DNS or ftp
  180. if test -z "$THREADS"; then
  181. printf "Checking for /usr/include/pthread.h.. "
  182. if test -f "/usr/include/pthread.h"; then
  183. if test -f "/usr/lib/libpthread.so"; then
  184.     printf "found\n"
  185.     THREADS=1
  186. else
  187.     printf "library not found (too bad), no threads will be available\n"
  188.     THREADS=
  189. fi
  190. else
  191.     printf "not found, no threads will be available\n"
  192.     THREADS=
  193. fi
  194. else
  195.     echo "Overriding THREADS=$THREADS"
  196. fi
  197.  
  198. # Sometimes, setuid and setgid can't be used (missing pwd.h and unistd.h ?!)
  199. if test -z "$NOUID"; then
  200. NOUID=1
  201. printf "Checking for /usr/include/pwd.h and /usr/include/unistd.h.. "
  202. if test -f "/usr/include/pwd.h"; then
  203. if test -f "/usr/include/unistd.h"; then
  204.     NOUID=
  205. fi
  206. fi
  207. if test -z "$NOUID"; then
  208.     printf "found\n"
  209. else
  210.     printf "not found, not using setuid() and setgid()\n"
  211. fi
  212. else
  213.     echo "Overriding NOUID=$NOUID"
  214. fi
  215.  
  216. # Sometimes, ftime can't be used (missing declaration...)
  217. if test -z "$NOFTIME"; then
  218. NOFTIME=1
  219. printf "Checking for ftime in /usr/include/sys/timeb.h.. "
  220. if grep "extern int ftime" /usr/include/sys/timeb.h >/dev/null; then
  221.     NOFTIME=
  222. fi
  223. if test -z "$NOFTIME"; then
  224.     printf "found\n"
  225. else
  226.     printf "not found (too bad), not using ftime()\n"
  227. fi
  228. else
  229.     echo "Overriding NOFTIME=$NOFTIME"
  230. fi
  231.  
  232. # Test variables
  233. if test "$NOUID" = 1; then
  234.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEUID__/HTS_DO_NOT_USE_UID/'"
  235. fi
  236. if test "$NOFTIME" = 1; then
  237.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEFTI__/HTS_DO_NOT_USE_FTIME/'"
  238. fi
  239. if test "$NODECLINADDRT" = 1; then
  240.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEINA__/HTS_DO_NOT_REDEFINE_in_addr_t/'"
  241. fi
  242. if test "$THREADS" = 1; then
  243.     SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$OTYPE $WTYPE -D_REENTRANT/g\""
  244.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__/-lpthread/g'"
  245. else
  246.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINEPTH__/HTS_DO_NOT_USE_PTHREAD/'"
  247.     SEDEXEC="$SEDEXEC | sed -e \"s/__CFLAGS__/$OTYPE $WTYPE/g\""
  248.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS__//g'"
  249. fi
  250. if test "$SOLSOCK" = 1; then
  251.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__/-lnsl -lsocket/g'"
  252. else
  253.     SEDEXEC="$SEDEXEC | sed -e 's/__LFLAGS2__//g'"
  254. fi
  255. if test ! "$LONGLONG" = 1; then
  256.     SEDEXEC="$SEDEXEC | sed -e 's/__DEFINE64B__/HTS_NO_64_BIT/'"
  257. fi
  258. SEDEXEC="$SEDEXEC | sed -e \"s/__PLATFORM__/$PLATFORM/g\""
  259. SEDEXEC="$SEDEXEC | sed -e 's/#__AUTONAME__/AUTONAME  = auto/'"
  260. SEDEXEC="$SEDEXEC | sed -e 's/#define __DEFINE.*__//g'"
  261. TMP=`echo $BINPATH | sed -e 's/\\//\\\\\\//g'` 
  262. SEDEXEC="$SEDEXEC | sed -e \"s/#__BINPATH__/BINPATH = $TMP/g\""
  263. TMP=`echo $PREFIX | sed -e 's/\\//\\\\\\//g'`
  264. SEDEXEC="$SEDEXEC | sed -e \"s/#__PREFIX__/PREFIX = $TMP/g\""
  265.  
  266. # Search for gmake
  267. printf "Checking for make.. "
  268. MAKEPATH=
  269. if test -f "/usr/bin/gmake"; then
  270. MAKEPATH=/usr/bin/gmake
  271. else
  272. if test -f "/bin/gmake"; then
  273. MAKEPATH=/bin/gmake
  274. else
  275. if test -f "/usr/local/bin/gmake"; then
  276. MAKEPATH=/usr/local/bin/gmake
  277. fi
  278. fi
  279. fi
  280. if test -n "$MAKEPATH"; then
  281. printf "found $MAKEPATH\n"
  282. else
  283. MAKEPATH=make
  284. printf "not found, assume make will work\n"
  285. fi
  286.  
  287. # Sed strip_cr
  288. printf "Checking for perl.. "
  289. PERLPATH=
  290. cp -f strip_cr.in strip_cr
  291. if test -f "/usr/bin/perl"; then
  292. PERLPATH=/usr/bin/perl
  293. else
  294. if test -f "/bin/perl"; then
  295. PERLPATH=/bin/perl
  296. else
  297. if test -f "/usr/local/bin/perl"; then
  298. PERLPATH=/usr/local/bin/perl
  299. fi
  300. fi
  301. fi
  302. if test -n "$PERLPATH"; then
  303. printf "found $PERLPATH\nEnsuring that *.c/*.h source files don't contains CR (^M).. "
  304. TMP=`echo $PERLPATH | sed -e 's/\\//\\\\\\//g'` 
  305. cat strip_cr | sed -e "s/__PERL__/$TMP/" >  __tmp; mv __tmp strip_cr
  306. chmod 700 strip_cr
  307. ./strip_cr *.c *.h
  308. printf "done\n"
  309. fi
  310.  
  311. # Sed all __VARS__
  312. CMD="cat Makefile $SEDEXEC > __tmp; mv __tmp Makefile"
  313. echo "Command: $CMD"
  314. if eval $CMD; then
  315.  
  316. echo ""
  317. echo "Makefile created!"
  318. echo "Type in '$MAKEPATH' to build and '$MAKEPATH install' to install"
  319.  
  320. if test -n "$DOMAKE"; then
  321.     echo "Making.."
  322.     eval $MAKEPATH clean
  323.     eval $MAKEPATH
  324. fi
  325. if test -n "$DOINSTALL"; then
  326.     echo "Installing.."
  327.     eval $MAKEPATH install
  328. fi
  329.  
  330. else
  331.     echo "Error while seding Makefile.."
  332. fi
  333.  
  334. else
  335.     echo "Error copying Makefile.in -> Makefile.. giving up"
  336. fi
  337.  
  338.